home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
fmtline.exe
/
FMTLINE.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1993-02-14
|
33KB
|
989 lines
{*******************************************************}
{ }
{ Turbo Pascal Version 6.0 }
{ Optional FormLine Unit for use with Turbo Vision }
{ Created and Copyright (c) 1991 J. John Sprenger }
{ }
{ Additional LatLong and Time formatlines }
{ created by S.A. Midwinter 74670,1306 }
{*******************************************************}
unit FmtLine; {revised from Formline, use in its place}
{$O+,F+,D+,R+,X+,S+}
interface {===========================================}
uses
{Turbo Pascal Run-Time Library Units}
Crt,
{Turbo Vision Standard Units}
Objects, Drivers, Views, Dialogs, App,
{Turbo Vision Accessory Units}
StdDlg, MsgBox;
const
{ flError, flCharOk and flFormatOK are constants used }
{ by tFormatLine.CheckPicture. flError is returned }
{ when an error is found, flCharOk when an character }
{ is found to be appropriate, And flFormatOk when the }
{ entire input string is found acceptable. }
flError = $0000;
flCharOK = $0001;
flFormatOK = $0002;
{ flCharError is passed to tFormatLine.ReportError }
{ when a character does not fit the proper form. }
{ flFormatError is used when the format is not }
{ satisfied even though input so far is acceptable. }
flCharError = 1;
flFormatError = 2;
{ CommandSet represents the characters used in Format }
{ Line Pictures. These match those used by Paradox. }
{ For more information, refer to the Paradox user's }
{ manual, which has many examples of picture strings. }
CommandSet = [ '[', '{', '?', '&', '''', '!', '#', '{',
',', ']', '}', '*'];
type
{ tFormatLine }
{ tFormatLine is the improved tInputLine object which }
{ accepts Paradox-form Picture strings to ensure that }
{ data will be entered in an acceptable form. }
pFormatLine = ^tFormatLine;
tFormatLine = object(tInputLine)
Picture : string;
constructor Init(var Bounds : tRect;
AMaxLen : integer; Pic : string);
function Valid(command : word) : boolean; virtual;
procedure HandleEvent(var Event : tEvent); virtual;
function CheckPicture(var s, Pic : string;
var CPos : integer):word;
procedure ReportError( kind : word); virtual;
end;
{ tMoneyFormatLine }
{ tMoneyFormatLine is an input line intended for use }
{ real number fields associated with money. Input is }
{ preceded with a "$" sign and terminated with a "." }
{ followed by the appropriate fractional value. }
pMoneyFormatLine = ^tMoneyFormatLine;
tMoneyFormatLine = object( tFormatLine )
constructor Init(var Bounds : tRect; AMaxlen : integer);
procedure SetData(var Rec); virtual;
procedure GetData(var Rec); virtual;
function DataSize : word; virtual;
end;
{ tPhoneFormatLine }
{ tPhoneFormatLine is for phone number fields. Normal }
{ 10-digit numbers are entered in the following form }
{ (###) ###-####. International numbers are entered }
{ digit after digit with spaces and hyphens where the }
{ user deems appropriate. }
pPhoneFormatLine = ^tPhoneFormatLine;
tPhoneFormatLine = object( tFormatLine )
constructor Init(var Bounds : tRect; AMaxLen : integer);
procedure SetData(var Rec); virtual;
procedure GetData(var Rec); virtual;
end;
{ tRealFormatLine }
{ tRealFormatLine is used for real number fields. It }
{ can handle both decimal and scientific notations. }
pRealFormatLine = ^tRealFormatLine;
tRealFormatLine = object ( tFormatLine )
constructor Init(var Bounds : tRect; AMaxLen : integer);
procedure SetData(var Rec); virtual;
procedure GetData(var Rec); virtual;
function DataSize : word; virtual;
end;
{ tIntegerFormatLine }
{ tIntegerFormatLine is used for integer fields. It }
{ accepts signed integers. }
pIntegerFormatLine = ^tIntegerFormatLine;
tIntegerFormatLine = object( tFormatLine )
constructor Init(var Bounds : tRect; AMaxLen : integer);
procedure SetData(var Rec); virtual;
procedure GetData(var Rec); virtual;
function DataSize : word; virtual;
end;
{ tNameFormatLine }
{ tNameFormatLine accepts words and capitalizes the }
{ first character of each word. This would be used }
{ proper names and addresses. }
pNameFormatLine = ^tNameFormatLine;
tNameFormatLine = object( tFormatLine )
constructor Init(var Bounds : tRect; AMaxLen : integer);
end;
{ tZipFormatLine }
{ tZipFormatLine is used for ZIP and Postal Code }
{ fields. It handles U.S. and Canadian format codes. }
pZipFormatLine = ^tZipFormatLine;
tZipFormatLine = object( tFormatLine )
constructor Init(var Bounds : tRect; AMaxLen : integer);
end;
{ tLatLongFormatLine } {added by Stewart Midwinter}
{ tLatLongFormatLine is used for geographical coor- }
{ dinates entered in fields. It can handle HH.hhhh }
{ and HH:MM:SS.ss notations. }
{ Limit is 90 for Latitudes and 180 for Longitudes }
pLatLongFormatLine = ^tLatLongFormatLine;
tLatLongFormatLine = object ( tFormatLine )
constructor Init(var Bounds: tRect; AMaxLen: integer);
procedure SetData(var Rec); virtual;
procedure GetData(var Rec); virtual; {NOTE: sends back a real; dialog record must be real}
function DataSize : word; virtual;
end;
{ the Lat object has a limit of 90 degrees, while the }
{ LatLong object has a limit of 180 degrees. This }
{ means that Lat allows only 2 digits before the deci-}
{ mal, while Long allows three digits before the deci-}
{ mal. To make it easier to validate, the Lat is limi-}
{ ted to 89.9999 and Long to 179.9999 degrees. }
{ note: Lat requires 2 and Long 3 digit before decimal}
{ tLatFormatLine }
pLatFormatLine = ^tLatFormatLine;
tLatFormatLine = object ( tLatLongFormatLine )
constructor Init(var Bounds: tRect; AMaxLen: integer);
procedure SetData(var Rec); virtual;
end;
{ tLongFormatLine }
pLongFormatLine = ^tLongFormatLine;
tLongFormatLine = object ( tLatLongFormatLine )
constructor Init(var Bounds: tRect; AMaxLen: integer);
end;
{ tTimeFormatLine is a descendant of LatLongFormatLine, since the}
{ notation is similar. The only difference is that times are lim-}
{ ited to 24 hours and latitudes to 90 degrees; the minutes and }
{ seconds and hundredths are the same. }
{ tTimeFormatLine can handle HH.hhhh or HH:MM:SS.ss formats }
{ tTimeFormatLine }
pTimeFormatLine = ^tTimeFormatLine;
tTimeFormatLine = object ( tLatLongFormatLine )
constructor Init(var Bounds: tRect; AMaxLen: integer);
end;
implementation {=========================================}
{ Function Copy represents a bit of syntactic sugar for }
{ the benefit of the author. It changes the Copy func. }
{ so that its parameters represent start and end points }
{ rather than a start point followed by a quantity. }
function Copy(s : string; start, stop : integer) : string;
begin
if stop < start then Copy:=''
else Copy:=System.Copy(s,start,stop-start+1);
end;
{ Function FindMatch recursively locates the matching }
{ grouping characters for "{" and "[". }
function FindMatch(P : string) : integer;
var
i:integer;
match:boolean;
c:char;